package cn.redcoral.messageplus.config;

import cn.messageplus.core.EnableMessagePlusCore;
import cn.messageplus.core.MessagePlusAgreement;
import cn.redcoral.messageplus.initialize.MessageInitialize;
import cn.redcoral.messageplus.properties.MessagePlusProperties;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;

/**
 * message-plus的普通配置类
 * @author mo
 **/
@Slf4j
@EnableCaching//开启基于注解的缓存支持
@EnableMessagePlusCore(MessagePlusAgreement.WEB_SOCKET)
@ComponentScan({"cn.redcoral.messageplus","cn.messageplus.core.message", "cn.messageplus.core.properties"})
@MapperScan("cn.redcoral.messageplus.data.mapper")
public class MessagePlusConfig {

    /**
     * 初始化消息服务
     * @return MessageInitialize的实例
     */
    @Bean
    public MessageInitialize messageInitialize() {
        log.info("MessagePlus is enabled...");
        log.info("MessagePlus ServiceId: {}", MessagePlusProperties.getServiceId());
        return new MessageInitialize();
    }

}
